package de.dubiel.plung.client.pages.start;

import com.google.gwt.cell.client.NumberCell;
import com.google.gwt.user.cellview.client.CellTable;
import com.google.gwt.user.cellview.client.Column;
import com.google.gwt.user.cellview.client.TextColumn;

import de.dubiel.plung.shared.dao.User;

/**
 * Definition einer Tabelle zum Anzeigen von Usern für die Gegenspielerwahl.
 * 
 * @author alike
 * 
 */
public class HighScoreList extends CellTable<User> {

    public HighScoreList() {
        this.setPageSize(25);
        TextColumn<User> nameColumn = new TextColumn<User>() {
            @Override
            public String getValue(User user) {
                return user.getName();
            }
        };
        this.addColumn(nameColumn, "Name");
        NumberCell scoreCell = new NumberCell();
        Column<User, Number> scoreColumn = new Column<User, Number>(scoreCell) {
            @Override
            public Long getValue(User user) {
                return user.getScore();
            }
        };
        this.addColumn(scoreColumn, "Punkte");
        NumberCell wonCell = new NumberCell();
        Column<User, Number> wonColumn = new Column<User, Number>(wonCell) {
            @Override
            public Integer getValue(User user) {
                return user.getWon();
            }
        };
        this.addColumn(wonColumn, "Gewonnen");
        NumberCell lostCell = new NumberCell();
        Column<User, Number> lostColumn = new Column<User, Number>(lostCell) {
            @Override
            public Integer getValue(User user) {
                return user.getLost();
            }
        };
        this.addColumn(lostColumn, "Verloren");
    }
}